Create vertical alignment from smart line
Smart line is set of connected lines and/or arcs. The vertical smart line can be created using ProfileComplex or ProfileLineString . The below code snippet shows how to create a smart line using ProfileComplex and create vertical alignment for it.
internal bool CreateVerticalAlignmentFromSmartLine(Alignment alignment)
{
//ConsensusConnectionEdit allows the persistence of civil objects to the dgn
Bentley.CifNET.SDK.Edit.ConsensusConnectionEdit con = Bentley.CifNET.SDK.Edit.ConsensusConnectionEdit.GetActive();
//Elements for creating profile parabola
System.Collections.Generic.List<ProfileElement> profElems = new System.Collections.Generic.List<ProfileElement>();
Bentley.GeometryNET.DPoint3d startPoint = new Bentley.GeometryNET.DPoint3d(0, 50.0);
Bentley.GeometryNET.DPoint3d vPI_Point = new Bentley.GeometryNET.DPoint3d(400.0, 58.0);
Bentley.GeometryNET.DPoint3d endPoint = new Bentley.GeometryNET.DPoint3d(800.0, 53.0);
double lengthOfVerticalCurve = 400.0;
//Create Profile parabola to create ProfileComplex object
Bentley.CifNET.LinearGeometry.ProfileLine baseElement1 = new Bentley.CifNET.LinearGeometry.ProfileLine(startPoint, vPI_Point);
Bentley.CifNET.LinearGeometry.ProfileLine baseElement2 = new Bentley.CifNET.LinearGeometry.ProfileLine(vPI_Point, endPoint);
Bentley.CifNET.LinearGeometry.ProfileParabola[] profileCurve = null;
Bentley.CifNET.LinearGeometry.ProfileElement profile = null;
if (baseElement1 as ProfileLine != null && baseElement2 as ProfileLine != null)
{
//Create profile parabola using 2 ProfileLine and length parameter
profileCurve = Bentley.CifNET.LinearGeometry.ProfileParabolaConstructor.CreateTangentParabolaTwoLinesByLength(baseElement1, baseElement2, lengthOfVerticalCurve);
profile = profileCurve[0];
}
//Create ProfileLines
Bentley.CifNET.LinearGeometry.ProfileLine entranceTangent = new ProfileLine(startPoint, profile.StartPoint.Coordinates);
profElems.Add(entranceTangent);
profElems.Add(profile);
Bentley.CifNET.LinearGeometry.ProfileLine exitTangent = new ProfileLine(profile.EndPoint.Coordinates, endPoint);
profElems.Add(exitTangent);
//Create ProfileComplex using 2 ProfileLine and one profile parabola
Bentley.CifNET.LinearGeometry.ProfileComplex profileComplex = new ProfileComplex(profElems.ToArray());
if (profileComplex == null) return false;
//Transient mode start for saving changes to dgn
con.StartTransientMode();
//Create profile from Smart line
Bentley.CifNET.GeometryModel.SDK.Profile verticalAlignment = alignment.CreateProfileByProfileElement(profileComplex, true, true);
if (verticalAlignment == null) return false;
//Set feature definition to profile
verticalAlignment.SetFeatureDefinition("Alignment\\Geom_Baseline", "VA");
//Save changes to dgn
con.PersistTransients();
return true;
}
Output
This image shows the profile created from the above code snippet.